package com.winit.cloudlink.mgmt.task;

import javax.annotation.Resource;
import java.util.List;

public class TaskRepositoryCassandraAdapter {
    @Resource
    private TaskRepository taskRepository;


    public Task getTask(String id) {
        return TaskPO.fromPO(taskRepository.findOne(id));
    }


    public Task getTaskByAreaAndName(String area, String name) {
        return TaskPO.fromPO(taskRepository.findByAreaAndName(area, name));
    }


    public List<Task> findTasks() {
        return TaskPO.fromPO(taskRepository.findAll());
    }


    public List<Task> findTasksByArea(String area) {
        return TaskPO.fromPO(taskRepository.findByArea(area));
    }


    public void saveTask(Task task) {
        taskRepository.save(TaskPO.toPO(task));
    }


    public void deleteTask(String id) {
        taskRepository.delete(id);
    }
}
